<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Bootstrap Admin</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="referrer" content="no-referrer"/>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="/static/lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="/static/lib/font-awesome/css/font-awesome.css">

    <script src="/static/lib/jquery-1.11.1.min.js" type="text/javascript"></script>


    <link rel="stylesheet" type="text/css" href="/static/stylesheets/theme.css">
    <link rel="stylesheet" type="text/css" href="/static/stylesheets/premium.css">

</head>
<body class=" theme-blue">

<!-- Demo page code -->

<script type="text/javascript">
    $(function () {
        var match = document.cookie.match(new RegExp('color=([^;]+)'));
        if (match) var color = match[1];
        if (color) {
            $('body').removeClass(function (index, css) {
                return (css.match(/\btheme-\S+/g) || []).join(' ')
            })
            $('body').addClass('theme-' + color);
        }

        $('[data-popover="true"]').popover({html: true});
    });

    function delcfm(url) {
        $('#url').val(url);//给会话中的隐藏属性URL赋值
    }

    function urlSubmit() {
        var url = $.trim($("#url").val());//获取会话中的隐藏属性URL
        console.log(url);
        window.location.href = url;
    }

    function edituser(ed0, ed1, ed2, ed3, ed5, ed6, ed7, ed8, ed9, ed10) {
        console.log(ed1);
        $('#ed1').attr('value', ed1);
        $('#ed2').attr('value', ed2);
        $('#ed3').attr('value', ed3);
        $('#ed5').attr('value', ed5);
        $('#ed6').attr('value', ed6);
        $('#ed7').attr('value', ed7);
        $('#ed8').attr('value', ed8);
        $('#ed9').attr('value', ed9);

        $('#edittab').attr('action', ed0)
    }


</script>
<style type="text/css">

    .navbar-default .navbar-brand, .navbar-default .navbar-brand:hover {
        color: #fff;
    }
</style>

<script type="text/javascript">
    $(function () {
        var uls = $('.sidebar-nav > ul > *').clone();
        uls.addClass('visible-xs');
        $('#main-menu').append(uls.clone());
    });
</script>


<div class="navbar navbar-default" role="navigation" style="height: 80px;">
    <div class="navbar-header">
        <a class=""><span class="navbar-brand" style="font-size: 20px;font-weight:bold;"><img
                src="/static/images/schoolBadge.png"
                style="height: 55px;width: 55px" alt=""/> 干部信息录入系统</span></a>
    </div>
    <div class="navbar-collapse collapse" style="height: 1px;">
        <ul id="main-menu" class="nav navbar-nav navbar-right">
            <li class="dropdown hidden-xs">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    <span class="glyphicon glyphicon-user padding-right-small"
                          style="position:relative;height: 49px;"></span>{{ user.user_name }}
                    <i class="fa fa-caret-down"></i>
                </a>
                <ul class="dropdown-menu">
                    <li><a tabindex="-1" href="/admin_loginout/">注销</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>


<div class="sidebar-nav">
    <ul>
        <li><a href="#" data-target=".dashboard-menu" class="nav-header" data-toggle="collapse"><i
                class="fa fa-fw fa-dashboard"></i> 用户管理<i class="fa fa-collapse"></i></a></li>
        <li>
            <ul class="dashboard-menu nav nav-list collapse in">
                <li><a href="/admin_index/"><span class="fa fa-caret-right"></span>用户数据</a></li>
                <li><a href="/admin_userlist/"><span class="fa fa-caret-right"></span> 用户列表</a></li>
            </ul>
        </li>

        <li><a href="#" data-target=".premium-menu" class="nav-header collapsed" data-toggle="collapse"><i
                class="fa fa-fw fa-fighter-jet"></i> 评奖评优管理<i class="fa fa-collapse"></i></a></li>
        <li>
            <ul class="premium-menu nav nav-list collapse">
                <li><a href="/admin_user_eva/"><span class="fa fa-caret-right"></span> 查看用户</a></li>
                <li><a href="/admin_eva_app/"><span class="fa fa-caret-right"></span> 未审核评优</a></li>
                <li><a href="/admin_eva_apped/"><span class="fa fa-caret-right"></span> 已通过评优</a></li>
                <li><a href="/admin_eva_unapp/"><span class="fa fa-caret-right"></span> 未通过评优</a></li>
            </ul>
        </li>
    </ul>
</div>

<div class="content">
    <div class="header">

        <h1 class="page-title">用户列表</h1>
        <ul class="breadcrumb">
            <li><a href="index.html">用户管理</a></li>
            <li class="active">用户列表</li>
        </ul>

    </div>
    <div class="main-content">

        <div class="btn-toolbar list-toolbar">
            <a href="#addUser" role="button" data-toggle="modal">
                <button class="btn btn-primary"><i class="fa fa-plus"></i> 添加用户</button>
            </a>
            <a href="#addUserList" role="button" data-toggle="modal">
                <button class="btn btn-primary"><i class="fa fa-upload"></i> 批量添加</button>
            </a>
            <div class="btn-group">
            </div>
        </div>
        <table class="table">
            <thead>
            <tr>
                <th>序号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>身份证</th>
                <th>出生年月</th>
                <th>联系方式</th>
                <th>邮箱地址</th>
                <th>籍贯</th>
                <th>所在单位</th>
                <th>证件照</th>
                <th style="width: 10em;"></th>
            </tr>
            </thead>
            <tbody>
            {% for user in users %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ user.user_name }}</td>
                    <td>{{ user.user_sex }}</td>
                    <td>{{ user.username }}</td>
                    <td>{{ user.user_birth }}</td>
                    <td>{{ user.user_phone }}</td>
                    <td>{{ user.user_email }}</td>
                    <td>{{ user.user_birthplace }}</td>
                    <td>{{ user.user_unit }}</td>
                    <td><img src="{{ user.user_photo.url }}" alt="" style="height: 100px;width: 70px"/></td>
                    <td>
                        <a href="#editUser" role="button" data-toggle="modal"
                           onclick="edituser('/admin_edituser/?id={{ user.id }}','{{ user.user_name }}','{{ user.user_sex }}','{{ user.user_birth }}','{{ user.user_phone }}','{{ user.user_email }}','{{ user.user_birthplace }}','{{ user.user_unit }}','{{ user.user_photo.url }}')"><i
                                class="fa fa-pencil"></i>&nbsp;修改</a>&nbsp;
                        <a href="#myModal" role="button" data-toggle="modal"
                           onclick="delcfm('/admin_deluser/?id={{ user.id }}')"><i
                                class="fa fa-trash-o"></i>&nbsp;删除</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <div id="url"></div>
        <div class="modal small fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">删除用户</h3>
                    </div>
                    <div class="modal-body">
                        <p class="error-text"><i class="fa fa-warning modal-icon"></i>是否确定删除？</p>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
                        <button class="btn btn-danger" data-dismiss="modal" onclick="urlSubmit()">删除</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal small fade" id="addUser" tabindex="-1" role="dialog" aria-labelledby="addUserLabel"
             aria-hidden="true">
            <div class="modal-dialog" style="width:550px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="addLabel">添加用户</h3>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-4">
                                <div id="myTabContent" class="tab-content">
                                    <div class="tab-pane active in" id="home">
                                        <form id="tab" method="POST" enctype="multipart/form-data"
                                              action="/admin_adduser/"
                                              style="width: 520px;">
                                            <div class="form-group">
                                                <label>姓名</label>
                                                <input type="text" class="form-control" name="user_name">
                                            </div>
                                            <div class="form-group">
                                                <label>性别</label>
                                                <input type="text" class="form-control" name="user_sex">
                                            </div>
                                            <div class="form-group">
                                                <label>出生年月</label>
                                                <input type="text" class="form-control" name="user_birth">
                                            </div>
                                            <div class="form-group">
                                                <label>身份证号码</label>
                                                <input type="text" class="form-control" name="card_id">
                                            </div>

                                            <div class="form-group">
                                                <label>联系方式</label>
                                                <input type="text" class="form-control" name="user_phone">
                                            </div>

                                            <div class="form-group">
                                                <label>邮箱地址</label>
                                                <input type="text" class="form-control" name="user_email">
                                            </div>
                                            <div class="form-group">
                                                <label>籍贯</label>
                                                <input type="text" class="form-control" name="user_birthplace">
                                            </div>
                                            <div class="form-group">
                                                <label>所在单位</label>
                                                <input type="text" class="form-control" name="user_unit">
                                            </div>
                                            <div class="form-group">
                                                <label>密码</label>
                                                <input type="password" class="form-control" name="user_pwd">
                                            </div>
                                            <div class="form-group">
                                                <label>证件照片</label>
                                                <input type="file" class="form-control" name="user_photo">
                                            </div>
                                            <div class="modal-footer">
                                                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">
                                                    Cancel
                                                </button>
                                                <input type="submit" class="btn btn-danger" name="添加" value="添加"
                                                       style="width: 75px;">
                                            </div>
                                        </form>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal small fade" id="editUser" tabindex="-1" role="dialog" aria-labelledby="editUserLabel"
             aria-hidden="true">
            <div class="modal-dialog" style="width:550px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="editLabel">修改用户</h3>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-md-4">
                                <div id="myTabContent" class="tab-content">
                                    <div class="tab-pane active in" id="home">
                                        <form id="edittab" method="POST" enctype="multipart/form-data"
                                              action=""
                                              style="width: 520px;">
                                            <div class="form-group">
                                                <label>姓名</label>
                                                <input type="text" class="form-control" name="user_name" id="ed1">
                                            </div>
                                            <div class="form-group">
                                                <label>性别</label>
                                                <input type="text" class="form-control" name="user_sex" id="ed2">
                                            </div>
                                            <div class="form-group">
                                                <label>出生年月</label>
                                                <input type="text" class="form-control" name="user_birth" id="ed3">
                                            </div>

                                            <div class="form-group">
                                                <label>联系方式</label>
                                                <input type="text" class="form-control" name="user_phone" id="ed5">
                                            </div>

                                            <div class="form-group">
                                                <label>邮箱地址</label>
                                                <input type="text" class="form-control" name="user_email" id="ed6">
                                            </div>
                                            <div class="form-group">
                                                <label>籍贯</label>
                                                <input type="text" class="form-control" name="user_birthplace" id="ed7">
                                            </div>
                                            <div class="form-group">
                                                <label>所在单位</label>
                                                <input type="text" class="form-control" name="user_unit" id="ed8">
                                            </div>
                                            <div class="form-group">
                                                <label>证件照片</label>
                                                <input type="file" class="form-control" name="user_photo" id="ed10">
                                            </div>
                                            <div class="modal-footer">
                                                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">
                                                    Cancel
                                                </button>
                                                <input type="submit" class="btn btn-danger" name="修改" value="修改"
                                                       style="width: 75px;" onclick="urlSubmit()">
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal small fade" id="addUserList" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h3 id="myModalLabel">批量添加用户</h3>
                    </div>
                    <a class="btn-danger pull-right" href="/admin_update_excel/">请先下载模板，点此处下载</a>
                    <form action="/admin_user_excel/" method="POST" enctype="multipart/form-data">
                        <div class="modal-body">
                            <input type="file" name="user_file"/>
                        </div>
                        <div class="modal-footer">
                            <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
                            <input type="submit" class="btn btn-danger" name="添加" value="添加"
                                   style="width: 75px;">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="/static/lib/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript">
    $("[rel=tooltip]").tooltip();
    $(function () {
        $('.demo-cancel-click').click(function () {
            return false;
        });
    });
</script>
{% if messages %}
    <script type="text/javascript">
        {% for msg in messages %}
            alert('{{ msg.message }}');
        {% endfor %}
    </script>
{% endif %}
</body>
</html>
